﻿Imports System.Data.SqlClient
Public Class frmFind
    Dim Var As New varDeclare
    Public QueryHeader As String
    Dim dsBase As New DataSet
    Public type As String
    Public cbValue As New ComboBox
    Public txtValue As New TextBox
    Public lblValue As New Label
    Public btnValue As New Button
    Public dgCellValue1 As DataGridViewCell
    Public dgCellValue2 As DataGridViewCell

    Private Sub frmFind_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
        MDI.Enabled = True
    End Sub

    Private Sub frmFind_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim connection As SqlConnection
        Dim adapter As SqlDataAdapter
        Dim command As New SqlCommand
        connection = New SqlConnection(Var.SUISConn)

        connection.Open()
        command.Connection = connection
        command.CommandText = QueryHeader
        adapter = New SqlDataAdapter(command)
        adapter.Fill(dsBase)
        connection.Close()

        GridAndFind1.Initialize(dsBase, Nothing, Nothing, Me, False)
    End Sub

    Private Sub dgvBase_DoubleClick(sender As Object) Handles GridAndFind1.GridDoubleClick
        Dim dgvBase As DataGridView = GridAndFind1.getDataGridView()
        Select Case type
            Case "cb"
                cbValue.Text = dgvBase.Item(0, dgvBase.CurrentRow.Index).Value.ToString()
            Case "cell"
                dgCellValue1.Value = dgvBase.Item(0, dgvBase.CurrentRow.Index).Value.ToString()
                dgCellValue2.Value = dgvBase.Item(1, dgvBase.CurrentRow.Index).Value.ToString()
            Case "txt"
                txtValue.Text = dgvBase.Item(0, dgvBase.CurrentRow.Index).Value.ToString()
            Case "lbl"
                lblValue.Text = dgvBase.Item(0, dgvBase.CurrentRow.Index).Value.ToString()
        End Select
        Me.Close()
    End Sub
End Class